package com.ssm.dao;

import com.ssm.bean.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 用户的持久层
 */
public interface IUserDao {

    //查询所有用户
    @Select("select * from user")
    public List<User> findAll();

    //查询用户根据id
    @Select("select * from user where id = #{id}")
    public User getUserById(Integer id);

    //保存用户
    @Insert("insert into user(username,address,sex,birthday) values(#{username},#{address},#{sex},#{birthday})")
    public void saveUser(User user);

    //更改用户
    @Update("update user set username=#{username},address=#{address},sex=#{sex},birthday=#{birthday} where id = #{id}")
    public void updateUser(User user);

    //删除用户
    @Delete("delete from user where id = #{id}")
    public void deleteUser(Integer id);

}
